package com.shao.dao;

import com.shao.bean.cls;
import com.shao.bean.teacher;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author: com.song shao
 * @date: 2022/2/28
 * @time: 10:08
 * @version: 1.0
 */
@SuppressWarnings("all")
public interface teaDao {

    /**
     * 查询教师的信息
     *
     * @return
     */
    @Select("select * from teacher")
    List<teacher> findTeacherInfos();

    /**
     * 查找教师所在的班级
     *
     * @param tea_class
     * @return
     */
    @Select("select * from cls where class_id=#{tea_class}")
    cls selectClass(@Param("tea_class") int tea_class);

    /**
     * 查询班级
     *
     * @return
     */
    @Select("select * from cls ")
    List<cls> selectCls();

    /**
     * 添加新的班级
     *
     * @param cl
     * @return
     */
    @Insert("insert into cls values  (#{class_id},#{class_name});")
    boolean insetClass(cls cl);

    /**
     * 添加新的老师账号
     *
     * @param teacher
     * @return
     */
    @Insert("insert into teacher values  (#{tea_username},#{tea_pwd},#{tea_code},#{tea_class},#{tea_state},#{tea_nikename});")
    boolean insertTeacher(teacher tea);

    /**
     * 查询教师的账号
     *
     * @param tea_username
     * @return
     */
    @Select("select * from teacher where tea_username = #{tea_username}")
    teacher findByTeacher(@Param("tea_username") String tea_username);

    /**
     * 更新状态
     *
     * @param tea_username
     * @param kry
     * @return
     */
    @Update("update teacher set tea_state=#{kry} where tea_username = #{tea_username}")
    int updataStatus(@Param("tea_username") String tea_username, @Param("kry") int kry);
}
